package wiki.douzi.helpyougrow.service.impl;

import wiki.douzi.helpyougrow.domain.Goods;
import wiki.douzi.helpyougrow.mapper.GoodsMapper;
import wiki.douzi.helpyougrow.service.GoodsService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

/**
 * (Goods)表服务实现类
 *
 * @author Douzi
 * @since 2022-06-18 16:39:18
 */
@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {
    @Resource
    private GoodsMapper goodsMapper;

    /**
     * 查询所有数据
     *
     * @return 实例对象集合
     */
    @Override
    public List<Goods> queryAll() {
        return this.goodsMapper.queryAll();
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Goods queryById(Integer id) {
        return this.goodsMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param goods 实例对象
     * @return 实例对象
     */
    @Override
    public Goods insert(Goods goods) {
        this.goodsMapper.insert(goods);
        return goods;
    }

    /**
     * 修改数据
     *
     * @param goods 实例对象
     * @return 实例对象
     */
    @Override
    public Goods update(Goods goods) {
        this.goodsMapper.update(goods);
        return this.queryById(goods.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.goodsMapper.deleteById(id) > 0;
    }

    @Override
    public List<Map<String, Object>> checkGoodsOrder() {
        return this.goodsMapper.checkGoodsOrder();
    }
}

